#include <stdio.h>
#include <stdbool.h>
#define ElementType int
#define Max 100

typedef struct
{
    ElementType arr[Max];
    int len;
    int front;
    int rear;
}Queue;

void InitQueue(Queue *q)
{
    for(int i = 0; i < Max; i++)
    {
        q->arr[i] = 0;
    }
    q->front = 0;
    q->rear = 0;
    q->len = 0;
}

void Push(Queue *q,ElementType element)
{
    if((q->rear + 1) % Max == q->front)
    {
        printf("队列满!\n");
        return;
    }
    q->arr[q->rear] = element;
    q->rear++;
    q->rear %= Max;
    q->len++;
}

void Pop(Queue *q)
{
    if(q->front == q->rear)
    {
        printf("队列空!\n");
        return;
    }
    q->front++;
    q->front %= Max;
    q->len--;
}

ElementType* GetPop(Queue *q)
{
    if(q->front == q->rear)
    {
        printf("队列空!\n");
        return NULL;
    }
    return &q->arr[q->front];
}

bool IsQueueEmpty(Queue *q)
{
    //return q->rear == q->front;
    return q->len == 0;
}


int main()
{
    Queue q;
    InitQueue(&q);
    for(int i = 1; i <= 10; i++)
    {
        Push(&q,i);
    }
    while(q.rear != q.front)
    {
        printf("%d ",*GetPop(&q));
        Pop(&q);
    }
    printf("\n");
    return 0;
}